import request from '@/utils/request'

/**
 *  获取子商品分类
 */
export const FindCategoryByParentId = id => {
  return request({
    url: `/admin/product/category/findByParentId/${id}`,
    method: 'get',
  })
}

/**
 *  获取所有品牌信息
 */
export const getAllBrand = () => {
  return request({
    url: `/admin/product/brand/findAll`,
    method: 'get',
  })
}

/**
 *  分页查询
 * @param pageNum
 * @param pageSize
 * @param queryRequest
 * @returns {AxiosPromise}
 */
export const findPage = (pageNum, pageSize, queryRequest) => {
  return request({
    url: `/admin/product/categoryBrand/findPage/${pageNum}/${pageSize}`,
    method: 'get',
    params: queryRequest,
  })
}

/**
 *  分页查询
 * @param pageNum
 * @param pageSize
 * @param queryRequest
 * @returns {AxiosPromise}
 */
export const doAddCategoryBrand = queryRequest => {
  return request({
    url: `/admin/product/categoryBrand/addCategoryBrand`,
    method: 'post',
    data: queryRequest,
  })
}

/**
 *  修改品牌分类
 * @param pageNum
 * @param pageSize
 * @param queryRequest
 * @returns {AxiosPromise}
 */
export const doUpdateCategoryBrand = (id, queryRequest) => {
  return request({
    url: `/admin/product/categoryBrand/updateCategoryBrand/${id}`,
    method: 'put',
    data: queryRequest,
  })
}

/**
 *  修改品牌分类
 * @param pageNum
 * @param pageSize
 * @param queryRequest
 * @returns {AxiosPromise}
 */
export const deleteCategoryBrand = id => {
  return request({
    url: `/admin/product/categoryBrand/deleteCategoryBrand/${id}`,
    method: 'delete',
  })
}
